// import React  from 'react';
import React, { useState, useEffect } from 'react';
import { NavBar, Space, Toast, TextArea, Button } from 'antd-mobile';
import { history } from 'umi';
import './index.css';
export default function index() {
  // 控制姓名的信息
  const [zhenname, setname] = useState();
  // 控制邮箱的信息
  const [email, setemail] = useState();
  // 控制问题的信息
  const [problem, setproblem] = useState();
  // 获取名字信息
  function changename(e) {
    setname(e.target.value);
  }
  // 获取邮箱信息
  function changeemail(e) {
    setemail(e.target.value);
  }
  // 获取问题信息
  function changeproblem(e) {
    setproblem(e.target.value);
  }
  // 返回按钮
  const back = () => {
    history.go(-1);
  };
  // 发送邮箱
  function send() {
    if ((zhenname == undefined) | (zhenname == '')) {
      Toast.show({
        icon: 'fail',
        content: '请输入真实姓名',
      });
      return false;
    }
    if ((email == undefined) | (email == '')) {
      Toast.show({
        icon: 'fail',
        content: '请输入邮箱',
      });
      return false;
    }
    if ((problem == undefined) | (problem == '')) {
      Toast.show({
        icon: 'fail',
        content: '请输入问题',
      });
      return false;
    }
    history.push('await');
  }
  return (
    <div className="alls">
      <NavBar onBack={back}>联系我们</NavBar>
      <div className="email">
        <TextArea
          placeholder="请输入你的真实姓名"
          defaultValue={zhenname}
          onBlur={(e) => {
            changename(e);
          }}
          style={{
            backgroundColor: 'white',
            marginTop: '0.5rem',
            paddingTop: '5px',
            paddingLeft: '5px',
          }}
        />
        <TextArea
          defaultValue={email}
          onBlur={(e) => {
            changeemail(e);
          }}
          placeholder="请输入你的邮箱"
          style={{
            backgroundColor: 'white',
            marginTop: '0.5rem',
            paddingTop: '5px',
            paddingLeft: '5px',
          }}
        />
        <TextArea
          defaultValue={problem}
          onBlur={(e) => {
            changeproblem(e);
          }}
          placeholder="请输入你的问题"
          rows={5}
          showCount
          maxLength={200}
          style={{
            backgroundColor: 'white',
            marginTop: '0.5rem',
            paddingTop: '5px',
            paddingLeft: '5px',
          }}
        />
        <Button
          block
          color="primary"
          size="large"
          style={{ marginTop: '0.5rem' }}
          onClick={send}
        >
          发送邮箱
        </Button>
      </div>
    </div>
  );
}
